package com.distribute.framework.model;

import com.distribute.framework.core.web.helper.Utils;
import java.lang.reflect.Field;
import java.util.Date; 
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;

import javax.annotation.Resource;

import com.distribute.framework.core.web.util.Page;
import com.distribute.framework.core.lang.*; 
import com.distribute.framework.core.web.helper.WebHelper.LzMap;
import com.distribute.framework.core.util.Function;
import com.distribute.framework.core.util.IbatisMap;
import com.distribute.framework.config.*;
import com.distribute.framework.plugin.*;

@namespace("coupons/directcoupon")
public @caption("定向优惠券") @database(DatabaseNames.distribute_sys) @source("distribute_sys") @table("direct_coupon") class DirectCoupon implements java.io.Serializable
{
	private static final long serialVersionUID = 1l;
	private @caption("编号") @column("id")    @primary  @notnull  @note("  ") Long id;// 主键 非空     
	private @caption("所属品牌") @column("merchant")     @notnull  @relate("$merchant") @RelateClass(Merchant.class)  @note("  ") Long merchant;// 非空     
 	private transient Merchant $merchant;//关联对象[品牌信息]
	private @caption("优惠券名称") @column("title")     @notnull  @note("  ") String title;// 非空     
	private @caption("生成数量") @column("count")     @notnull  @note("  ") Integer count;// 非空     
	private @caption("折扣") @column("discount")     @notnull  @note("  最大设9.9折 不能大于等于10  也不能为负数") Double discount;// 非空  最大设9.9折 不能大于等于10  也不能为负数   
	private @caption("规则介绍") @column("introduction") @like  @hidden   @notnull  @note("  ") String introduction;// 非空     
	private @caption("截止时间") @column("deadline")     @notnull  @note("  ") Date deadline;// 非空     
	private @caption("定向投放对象") @column("direct_object")      @note(" 1:全部用户 2:消费金额满 3:注册时间满 4:指定用户  ") Short directObject;// 1:全部用户 2:消费金额满 3:注册时间满 4:指定用户     
	private @caption("消费累计满领") @column("accumulated_full")      @note("  ") Double accumulatedFull;//     
	private @caption("注册满天数领") @column("full_day")      @note("  ") Integer fullDay;//     
	private @caption("指定用户") @column("desig_user")      @relate("$desigUser") @RelateClass(Member.class)  @note("  ") Long desigUser;//     
 	private transient Member $desigUser;//关联对象[会员信息]
	private @caption("已领取数量") @column("received")     @notnull  @note("  ") Integer received;// 非空     
	private @caption("已使用数量") @column("used")     @notnull  @note("  ") Integer used;// 非空     
	private @caption("适用商品") @column("commodity")     @notnull  @relate("$commodity") @RelateClass(Commodity.class)  @note("  ") Long commodity;// 非空     
 	private transient Commodity $commodity;//关联对象[商品信息]
	private @caption("修改时间") @column("update_time")     @notnull  @note("  ") Date updateTime;// 非空     
	private @caption("添加时间") @column("add_time")     @notnull  @note("  ") Date addTime;// 非空     
	private @caption("状态") @column("status")     @notnull  @note(" 1:正常 0:无效  ") Short status;// 非空 1:正常 0:无效     
	 
	//默认构造函数
	public DirectCoupon(){ 
	
	}
	
	//主键构造函数
	public DirectCoupon(Long id){
		this.id = id;
	}
	
	/**所有字段构造函数 
	 DirectCoupon(
	 	Utils.getLong("merchant")//所属品牌 [非空]
	 	,Utils.getString("title")//优惠券名称 [非空]
	 	,Utils.getInteger("count")//生成数量 [非空]
	 	,Utils.getDouble("discount")//折扣 [非空]
	 	,Utils.getString("introduction")//规则介绍 [非空]
	 	,Utils.getDate("deadline")//截止时间 [非空]
	 	,Utils.getShort("directObject")//定向投放对象
	 	,Utils.getDouble("accumulatedFull")//消费累计满领
	 	,Utils.getInteger("fullDay")//注册满天数领
	 	,Utils.getLong("desigUser")//指定用户
	 	,Utils.getInteger("received")//已领取数量 [非空]
	 	,Utils.getInteger("used")//已使用数量 [非空]
	 	,Utils.getLong("commodity")//适用商品 [非空]
	 	,Utils.getDate("updateTime")//修改时间 [非空]
	 	,Utils.getDate("addTime")//添加时间 [非空]
	 	,Utils.getShort("status")//状态 [非空]
	 )
	**/
	public DirectCoupon(Long merchant,String title,Integer count,Double discount,String introduction,Date deadline,Short directObject,Double accumulatedFull,Integer fullDay,Long desigUser,Integer received,Integer used,Long commodity,Date updateTime,Date addTime,Short status){
		this.merchant=merchant;
		this.title=title;
		this.count=count;
		this.discount=discount;
		this.introduction=introduction;
		this.deadline=deadline;
		this.directObject=directObject;
		this.accumulatedFull=accumulatedFull;
		this.fullDay=fullDay;
		this.desigUser=desigUser;
		this.received=received;
		this.used=used;
		this.commodity=commodity;
		this.updateTime=updateTime;
		this.addTime=addTime;
		this.status=status;
	}
	
	//设置非空字段
	public DirectCoupon setNotNull(Long merchant,String title,Integer count,Double discount,String introduction,Date deadline,Integer received,Integer used,Long commodity,Date updateTime,Date addTime,Short status){
		this.merchant=merchant;
		this.title=title;
		this.count=count;
		this.discount=discount;
		this.introduction=introduction;
		this.deadline=deadline;
		this.received=received;
		this.used=used;
		this.commodity=commodity;
		this.updateTime=updateTime;
		this.addTime=addTime;
		this.status=status;
		return this;
	}
	/** 编号 [非空]       **/
	public DirectCoupon id(Long id){
		this.id = id;
		this.setSeted(F.id);
		return this;
	}
	/** 所属品牌 [非空] [Merchant]      **/
	public DirectCoupon merchant(Long merchant){
		this.merchant = merchant;
		this.setSeted(F.merchant);
		return this;
	}
	/** 优惠券名称 [非空]       **/
	public DirectCoupon title(String title){
		this.title = title;
		this.setSeted(F.title);
		return this;
	}
	/** 生成数量 [非空]       **/
	public DirectCoupon count(Integer count){
		this.count = count;
		this.setSeted(F.count);
		return this;
	}
	/** 折扣 [非空]    最大设9.9折 不能大于等于10  也不能为负数   **/
	public DirectCoupon discount(Double discount){
		this.discount = discount;
		this.setSeted(F.discount);
		return this;
	}
	/** 规则介绍 [非空]       **/
	public DirectCoupon introduction(String introduction){
		this.introduction = introduction;
		this.setSeted(F.introduction);
		return this;
	}
	/** 截止时间 [非空]       **/
	public DirectCoupon deadline(Date deadline){
		this.deadline = deadline;
		this.setSeted(F.deadline);
		return this;
	}
	/** 定向投放对象    1:全部用户 2:消费金额满 3:注册时间满 4:指定用户     **/
	public DirectCoupon directObject(Short directObject){
		this.directObject = directObject;
		this.setSeted(F.directObject);
		return this;
	}
	/** 消费累计满领        **/
	public DirectCoupon accumulatedFull(Double accumulatedFull){
		this.accumulatedFull = accumulatedFull;
		this.setSeted(F.accumulatedFull);
		return this;
	}
	/** 注册满天数领        **/
	public DirectCoupon fullDay(Integer fullDay){
		this.fullDay = fullDay;
		this.setSeted(F.fullDay);
		return this;
	}
	/** 指定用户  [Member]      **/
	public DirectCoupon desigUser(Long desigUser){
		this.desigUser = desigUser;
		this.setSeted(F.desigUser);
		return this;
	}
	/** 已领取数量 [非空]       **/
	public DirectCoupon received(Integer received){
		this.received = received;
		this.setSeted(F.received);
		return this;
	}
	/** 已使用数量 [非空]       **/
	public DirectCoupon used(Integer used){
		this.used = used;
		this.setSeted(F.used);
		return this;
	}
	/** 适用商品 [非空] [Commodity]      **/
	public DirectCoupon commodity(Long commodity){
		this.commodity = commodity;
		this.setSeted(F.commodity);
		return this;
	}
	/** 修改时间 [非空]       **/
	public DirectCoupon updateTime(Date updateTime){
		this.updateTime = updateTime;
		this.setSeted(F.updateTime);
		return this;
	}
	/** 添加时间 [非空]       **/
	public DirectCoupon addTime(Date addTime){
		this.addTime = addTime;
		this.setSeted(F.addTime);
		return this;
	}
	/** 状态 [非空]   1:正常 0:无效     **/
	public DirectCoupon status(Short status){
		this.status = status;
		this.setSeted(F.status);
		return this;
	}
	
	
	/**
	* 克隆对象
	**/
	public DirectCoupon clone(){
		DirectCoupon clone = new DirectCoupon();
		clone.merchant=this.merchant;
		clone.title=this.title;
		clone.count=this.count;
		clone.discount=this.discount;
		clone.introduction=this.introduction;
		clone.deadline=this.deadline;
		clone.directObject=this.directObject;
		clone.accumulatedFull=this.accumulatedFull;
		clone.fullDay=this.fullDay;
		clone.desigUser=this.desigUser;
		clone.received=this.received;
		clone.used=this.used;
		clone.commodity=this.commodity;
		clone.updateTime=this.updateTime;
		clone.addTime=this.addTime;
		clone.status=this.status;
		return clone;
	}
	
	
	/**
	 * 根据ID取定向优惠券
	 * @param id
	 * @return
	 */
	public static @api DirectCoupon get(Long id){		
		return getDirectCouponById(id);
	}
	
	/**
	 * 获取所有定向优惠券
	 * @return
	 */
	public static @api List<DirectCoupon> list(Map params,Integer size){
		return getDirectCouponList(params,size);
	}
	/**
	 * 获取定向优惠券分页
	 * @return
	 */
	public static @api Page<DirectCoupon> page(Integer page,Integer size,Map params){
		return getDirectCouponPage(page, size , params);
	}
	
	
	/**
	 * 根据查询条件取定向优惠券
	 * @param params
	 * @return
	 */
	public static @api DirectCoupon Get(Map params){
		return getDirectCoupon(params);
	}
	/**
	 * 获取定向优惠券数
	 * @return
	 */
	public static @api Long count(Map params){
		return getDirectCouponCount(params);
	}
	/**
	 * 获取定向优惠券数
	 * @return
	 */
	public static @api <T> T eval(String eval,Map params){
		return getDirectCouponEval(eval,params);
	}
	/**
	 * 获取定向优惠券图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey){
		return getDirectCouponStats(params,sumKey,groupKey,-1);
	}
	/**
	 * 获取定向优惠券图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey,int dateType){
		return getDirectCouponStats(params,sumKey,groupKey,dateType);
	}
	
	/**
	 * 根据ID取定向优惠券
	 * @param id
	 * @return
	 */
	public static @api DirectCoupon getDirectCouponById(Long id){		
		return getDirectCouponDao().getDirectCouponById(id);
	}
	
	
	/**
	 * 根据ID取定向优惠券的标识键值
	 * @param id
	 * @return
	 */
	public static @api String getKeyValue(Object key){
		Long id = Utils.parseLong(key);	
		if(id==null || id.longValue()==0 ){
			return null;
		}
		String value = null;
		if(value==null){
			DirectCoupon directCoupon = get(id);
			if(directCoupon!=null){
				String strValue = directCoupon.getId$();
				value = strValue;
			}else{
				value = "{"+id+"}";
			}
		}
		/************LAZY3Q_ID_KEYVALUE************/
		/************LAZY3Q_ID_KEYVALUE************/
		return value;
	}	
	
	
	/**
	 * 获取当前对象的键值
	 * @return
	 */
	public String getKeyValue(){
		/************LAZY3Q_CODE_KEYVALUE************/
		/************LAZY3Q_CODE_KEYVALUE************/
		String keyValue = this.getId$();
		return keyValue;
	}
	
	
	/**
	 * 根据关键字精确查询定向优惠券对象
	 * @return
	 */
	public static @api DirectCoupon find(String key){
		if(Utils.empty(key))return null;
		Map params = new HashMap();
		if(key.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
			params.put("id", key.toLowerCase().replaceFirst("id:", ""));					
		else{//按标识查询，精确查询
			String strDefinex = "";
			strDefinex="(2=1 "+strDefinex+")";
			params.put("definex",strDefinex);
		}
		/************LAZY3Q_CODE_FIND************/
		/************LAZY3Q_CODE_FIND************/
		return DirectCoupon.getDirectCoupon(params);
	}
	
	
	/**
	 * 根据关键字查询定向优惠券
	 * @return
	 */
	public static @api List<Map> query(String key,int size,Map params,Boolean bObject){
		if(Utils.empty((String)params.get("asc")) && Utils.empty((String)params.get("desc")))//如果未传入排序字段
			params.put("desc","id");//那么，默认以主键降序，传给Dao层
		String strTerm=key;		
		if(!Utils.empty(strTerm)){
			if(strTerm.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
				params.put("id", strTerm.toLowerCase().replaceFirst("id:", ""));					
			else//按标识查询，模糊查询请带%
			{
				String strDefinex = "";
				strDefinex="(2=1 "+strDefinex+")";
				params.put("definex",strDefinex);
			}
		}
		/************LAZY3Q_CODE_QUERY************/
		/************LAZY3Q_CODE_QUERY************/
			
		List<DirectCoupon> list = page(0,size,params).getResult();
		
		/**
		* OK!取到数据拼成放入Map中，[{value,text,object:{...}},...]
		* value:数据ID，text:数据标识,object,整个对象
		**/
		List<Map> result = new java.util.ArrayList();
		for(DirectCoupon directCoupon:list){
			Map map = new HashMap();
			map.put("key",directCoupon.getId().toString());
			map.put("value", Utils.js(directCoupon.getKeyValue()));
			if(bObject==true)
				map.put("object",directCoupon);
			result.add(map);
		}
		/************LAZY3Q_AFTER_QUERY************/
		/************LAZY3Q_AFTER_QUERY************/
		
		return result;
	}
	
	
	
	/**
	 * 获取所有定向优惠券
	 * @return
	 */
	public static @api List<DirectCoupon> getDirectCouponList(Map params,Integer size){
		return getDirectCouponDao().getDirectCouponList(params,0,size);
	}
	
	/**
	 * 获取定向优惠券分页
	 * @return
	 */
	public static @api Page<DirectCoupon> getDirectCouponPage(Integer page,Integer size,Map params){
		if(page==null)page=0;
		if(size==null)size=20;
		return getDirectCouponDao().getDirectCouponPage(page, size , params);
	}
	
	/**
	 * 根据查询条件取定向优惠券
	 * @param params
	 * @return
	 */
	public static @api DirectCoupon getDirectCoupon(Map params){
		return getDirectCouponDao().getDirectCoupon(params);
	}
	
	/**
	 * 保存一个定向优惠券
	 * @param directCoupon
	 * @return
	 */
	public static @api DirectCoupon saveDirectCoupon(DirectCoupon directCoupon){
		return getDirectCouponDao().saveDirectCoupon(directCoupon);
	}
	
	/**
	 * 根据条件更新定向优惠券
	 * @param values
	 * @param params
	 */
	public static @api int updateDirectCouponByConfirm(Map values, Map params){
		return getDirectCouponDao().updateDirectCouponByConfirm(values,params);
	}
	
	/**
	 * 修改一个定向优惠券
	 * @param directCoupon
	 * @return
	 */
	public static @api int updateDirectCoupon(DirectCoupon directCoupon){
		return getDirectCouponDao().updateDirectCoupon(directCoupon);
	}
	
	/**
	 * 更新定向优惠券非空字段
	 * @param directCoupon
	 */
	public static @api int updateDirectCoupon$NotNull(DirectCoupon directCoupon){
		return getDirectCouponDao().updateDirectCoupon$NotNull(directCoupon);
	}
	
	/**
	 * 获取定向优惠券数
	 * @return
	 */
	public static @api Long getDirectCouponCount(Map params){
		return getDirectCouponDao().getDirectCouponCount(params);
	}
		
		
	/**
	 * 获取定向优惠券自定义求和表达式,比如求和:eval="sum(id)"
	 * @return
	 */	
	public static @api <T> T getDirectCouponEval(String eval,Map params){
		return getDirectCouponDao().getDirectCouponEval(eval,params);
	}
	/**
	 * 获取定向优惠券图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> getDirectCouponStats(Map params,C sumKey,C groupKey,int dateType){
		//TODO:图表统计功能未实现
		
		Map<String,Object> groups=new HashMap();//要分组的字段
		Map<String,Object> sums=new HashMap();//要统计的字段
		
		String[][] dateFormats=new String[][]{
				null,
				new String[]{"%Y","yyyy年","Y"},
				new String[]{"%Y-%m","yyyy年MM月","M"},
				new String[]{"%Y%U","yyyy年第ww周","W"},
				new String[]{"%Y-%m-%d","yyyy年MM月dd日","D"},
				new String[]{"%Y-%m-%d %H","yyyy年MM月dd日 HH点","H"},
				new String[]{"%m","MM月"},
				new String[]{"%d","dd号"},
				new String[]{"%H","HH点"} 
		};
		
		//获取要分组的字段，放入Map中
		if(dateType>0){
			groups.put(groupKey.toString(),"DATE_FORMAT({key},'"+dateFormats[dateType][0]+"')");
		}else{
			groups.put(groupKey.toString(),"{key}");
		}
		if(dateType<6 && dateType>0){ 
			params.put("asc", groupKey.toString()); 
			if(params.get(groupKey.name()+"Start")==null){
				params.put(groupKey.name()+"Start", Utils.date(new Date(), -24, dateFormats[dateType][2]));
			}
		}
		
		
		//获取要统计的字段，放入Map中
		if(sumKey.toString().equals("count")){
			sums.put(sumKey.toString(),"count(*)");
		}else{
			sums.put(sumKey.toString(),"sum({key})");
		}
		
		List<Map> list = getDirectCouponDao().getDirectCouponStats(params,groups,sums);
		
		List<Map> result = new ArrayList();
		for(Map m:list){
			Map map = new HashMap();
			Object value = m.get(sumKey.toString());
			Object name = null;
			Object groupValue = m.get(groupKey.toString());
			if(dateType>0){
				name = Utils.date(Utils.parseDate(groupValue), dateFormats[dateType][1]);
			}else{
				try{
					java.lang.reflect.Method method = DirectCoupon.class.getMethod("get"+Utils.ForMat(groupKey.toString())+"$");
					method.setAccessible(true);
					name = method.invoke(DirectCoupon.fromMap(m));
				}catch(Exception ex){
					ex.printStackTrace();
				}
			}
			map.put("name", name);
			map.put("value", value);
			result.add(map);
		}
		return result;
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static int updateDirectCoupon(Map set,Map where){
		if(set.isEmpty())throw new RuntimeException("set为空");
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		return getDirectCouponDao().updateDirectCouponByConfirm(set, where);
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void deleteDirectCoupon(Map where){
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		getDirectCouponDao().deleteDirectCouponByConfirm(where);
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void delete(Long id){
		if(id==null)throw new RuntimeException("id为空");
		getDirectCouponDao().removeDirectCouponById(id);
	}
	
	
	/**
	 * 保存定向优惠券对象
	 * @param params
	 * @return
	 */
	public DirectCoupon save(){
		if(this.getId()!=null)
			getDirectCouponDao().updateDirectCoupon(this);
		else
			return getDirectCouponDao().saveDirectCoupon(this);
		return this;
	}
	
	
	/**
	 * 更新定向优惠券对象的非空字段,注意跟Service里面的update不一样哦
	 * @param params
	 * @return
	 */
	public int update(){
		return getDirectCouponDao().updateDirectCoupon$NotNull(this);
	}
	
	
	/**
	 * 删除
	 * @param params
	 * @return
	 */
	public void delete(){
		if(Utils.equals(Utils.config("logic_delete"),"true"))
			getDirectCouponDao().removeDirectCouponById(this.getId());
		else
			getDirectCouponDao().deleteDirectCouponById(this.getId());
	}
	
	/**
	 * 执行事务
	 * @param function
	 */
	public static <T> T execute(Function function){
		return getDirectCouponDao().executeTransaction(function);
	}
	/*******************************编号**********************************/	
	/**
	* 编号 [非空]      
	**/
	public Long getId(){
		if(this.id!=null){
			return this.id;
		}
		return this.id;
	}
	/**
	* 获取编号格式化(toString)
	**/
	public String getId$(){
		String strValue="";
		 strValue=Utils.string(this.getId());
	 	 return strValue;
	}
	/**
	* 根据编号反格式化
	**/
	public void setId$(String strValue){
		if(Utils.empty(strValue)){
			this.id=null;
			return;
		}
	 	this.id=Utils.parseLong(strValue);
	}
	
	/**
	* 编号 [非空]      
	**/
	public void setId(Long id){
		this.id = id;
		this.setSeted(F.id);
	}
	
	
	
	
	/*******************************所属品牌**********************************/	
	/**
	* 所属品牌 [非空] [Merchant]     
	**/
	public Long getMerchant(){
		if(this.merchant!=null){
			return this.merchant;
		}
		return this.merchant;
	}
	/**
	* 获取所属品牌格式化(toString)
	**/
	public String getMerchant$(){
		String strValue="";
		if(this.getMerchant()!=null){
				strValue+=Utils.string(Merchant.getKeyValue(this.getMerchant()));
		}			
	 	 return strValue;
	}
	/**
	* 根据所属品牌反格式化
	**/
	public void setMerchant$(String strValue){
		if(Utils.empty(strValue)){
			this.merchant=null;
			return;
		}
		Merchant item = Merchant.find(strValue);
		if(item!=null){
			this.merchant = Utils.parseLong(item.getId());
		}
	}
	
	/**
	* 所属品牌 [非空] [Merchant]     
	**/
	public void setMerchant(Long merchant){
		this.merchant = merchant;
		this.setSeted(F.merchant);
	}
	
	
	
	
	/**
	* 获取关联对象[品牌信息]
	**/	 			
 	public Merchant get$merchant(){
 		if(this.$merchant!=null)
 			return this.$merchant;
 		com.distribute.framework.model.Merchant merchant = null;
		if(this.getMerchant()!=null){
 			merchant = Merchant.get(this.getMerchant());
 		}
 		return merchant;
	}
	/*******************************优惠券名称**********************************/	
	/**
	* 优惠券名称 [非空]      
	**/
	public String getTitle(){
		if(this.title!=null){
			return this.title;
		}
		return this.title;
	}
	/**
	* 获取优惠券名称格式化(toString)
	**/
	public String getTitle$(){
		String strValue="";
		 strValue=Utils.string(this.getTitle());
	 	 return strValue;
	}
	/**
	* 根据优惠券名称反格式化
	**/
	public void setTitle$(String strValue){
		if(Utils.empty(strValue)){
			this.title=null;
			return;
		}
	 	this.title=strValue;
	}
	
	/**
	* 优惠券名称 [非空]      
	**/
	public void setTitle(String title){
		this.title = title;
		this.setSeted(F.title);
	}
	
	
	
	
	/*******************************生成数量**********************************/	
	/**
	* 生成数量 [非空]      
	**/
	public Integer getCount(){
		if(this.count!=null){
			return this.count;
		}
		return this.count;
	}
	/**
	* 获取生成数量格式化(toString)
	**/
	public String getCount$(){
		String strValue="";
		 strValue=Utils.string(this.getCount());
	 	 return strValue;
	}
	/**
	* 根据生成数量反格式化
	**/
	public void setCount$(String strValue){
		if(Utils.empty(strValue)){
			this.count=null;
			return;
		}
	 	this.count=Utils.parseInteger(strValue);
	}
	
	/**
	* 生成数量 [非空]      
	**/
	public void setCount(Integer count){
		this.count = count;
		this.setSeted(F.count);
	}
	
	
	
	
	/*******************************折扣**********************************/	
	/**
	* 折扣 [非空]    最大设9.9折 不能大于等于10  也不能为负数  
	**/
	public Double getDiscount(){
		if(this.discount!=null){
			return this.discount;
		}
		return this.discount;
	}
	/**
	* 获取折扣格式化(toString)
	**/
	public String getDiscount$(){
		String strValue="";
		 strValue=Utils.string(this.getDiscount());	
	 	 return strValue;
	}
	/**
	* 根据折扣反格式化
	**/
	public void setDiscount$(String strValue){
		if(Utils.empty(strValue)){
			this.discount=null;
			return;
		}
	 	this.discount=Utils.parseDouble(strValue);
	}
	
	/**
	* 折扣 [非空]    最大设9.9折 不能大于等于10  也不能为负数  
	**/
	public void setDiscount(Double discount){
		this.discount = discount;
		this.setSeted(F.discount);
	}
	
	
	
	
	/*******************************规则介绍**********************************/	
	/**
	* 规则介绍 [非空]      
	**/
	public String getIntroduction(){
		if(this.introduction!=null){
			return this.introduction;
		}
		return this.introduction;
	}
	/**
	* 获取规则介绍格式化(toString)
	**/
	public String getIntroduction$(){
		String strValue="";
		 strValue=Utils.string(this.getIntroduction());
	 	 return strValue;
	}
	/**
	* 根据规则介绍反格式化
	**/
	public void setIntroduction$(String strValue){
		if(Utils.empty(strValue)){
			this.introduction=null;
			return;
		}
		this.introduction=strValue;
	}
	
	/**
	* 规则介绍 [非空]      
	**/
	public void setIntroduction(String introduction){
		this.introduction = introduction;
		this.setSeted(F.introduction);
	}
	
	
	
	
	/*******************************截止时间**********************************/	
	/**
	* 截止时间 [非空]      
	**/
	public Date getDeadline(){
		if(this.deadline!=null){
			return this.deadline;
		}
		return this.deadline;
	}
	/**
	* 获取截止时间格式化(toString)
	**/
	public String getDeadline$(){
		String strValue="";
		 strValue=Utils.string(Utils.date(this.getDeadline(),"yyyy-MM-dd"));
	 	 return strValue;
	}
	/**
	* 根据截止时间反格式化
	**/
	public void setDeadline$(String strValue){
		if(Utils.empty(strValue)){
			this.deadline=null;
			return;
		}
	 	this.deadline=Utils.date(strValue,"yyyy-MM-dd");
	}
	
	/**
	* 截止时间 [非空]      
	**/
	public void setDeadline(Date deadline){
		this.deadline = deadline;
		this.setSeted(F.deadline);
	}
	
	
	
	
	/*******************************定向投放对象**********************************/	
	/**
	* 定向投放对象    1:全部用户 2:消费金额满 3:注册时间满 4:指定用户    
	**/
	public Short getDirectObject(){
		if(this.directObject!=null){
			return this.directObject;
		}
		return this.directObject;
	}
	/**
	* 获取定向投放对象格式化(toString)
	**/
	public String getDirectObject$(){
		String strValue="";
		 if(Utils.equals(Utils.string(this.getDirectObject()),"1"))
			strValue=Utils.string("全部用户");		 
		 if(Utils.equals(Utils.string(this.getDirectObject()),"2"))
			strValue=Utils.string("消费金额满");		 
		 if(Utils.equals(Utils.string(this.getDirectObject()),"3"))
			strValue=Utils.string("注册时间满");		 
		 if(Utils.equals(Utils.string(this.getDirectObject()),"4"))
			strValue=Utils.string("指定用户");		 
	 	 return strValue;
	}
	/**
	* 根据定向投放对象反格式化
	**/
	public void setDirectObject$(String strValue){
		if(Utils.empty(strValue)){
			this.directObject=null;
			return;
		}
		 if(Utils.equals(strValue,"全部用户"))
		 	this.directObject=Utils.parseShort("1");
		 if(Utils.equals(strValue,"消费金额满"))
		 	this.directObject=Utils.parseShort("2");
		 if(Utils.equals(strValue,"注册时间满"))
		 	this.directObject=Utils.parseShort("3");
		 if(Utils.equals(strValue,"指定用户"))
		 	this.directObject=Utils.parseShort("4");
	}
	
	/**
	* 定向投放对象    1:全部用户 2:消费金额满 3:注册时间满 4:指定用户    
	**/
	public void setDirectObject(Short directObject){
		this.directObject = directObject;
		this.setSeted(F.directObject);
	}
	
	
	
	
	/*******************************消费累计满领**********************************/	
	/**
	* 消费累计满领       
	**/
	public Double getAccumulatedFull(){
		if(this.accumulatedFull!=null){
			return this.accumulatedFull;
		}
		return this.accumulatedFull;
	}
	/**
	* 获取消费累计满领格式化(toString)
	**/
	public String getAccumulatedFull$(){
		String strValue="";
		 strValue=Utils.string(this.getAccumulatedFull());	
	 	 return strValue;
	}
	/**
	* 根据消费累计满领反格式化
	**/
	public void setAccumulatedFull$(String strValue){
		if(Utils.empty(strValue)){
			this.accumulatedFull=null;
			return;
		}
	 	this.accumulatedFull=Utils.parseDouble(strValue);
	}
	
	/**
	* 消费累计满领       
	**/
	public void setAccumulatedFull(Double accumulatedFull){
		this.accumulatedFull = accumulatedFull;
		this.setSeted(F.accumulatedFull);
	}
	
	
	
	
	/*******************************注册满天数领**********************************/	
	/**
	* 注册满天数领       
	**/
	public Integer getFullDay(){
		if(this.fullDay!=null){
			return this.fullDay;
		}
		return this.fullDay;
	}
	/**
	* 获取注册满天数领格式化(toString)
	**/
	public String getFullDay$(){
		String strValue="";
		 strValue=Utils.string(this.getFullDay());
	 	 return strValue;
	}
	/**
	* 根据注册满天数领反格式化
	**/
	public void setFullDay$(String strValue){
		if(Utils.empty(strValue)){
			this.fullDay=null;
			return;
		}
	 	this.fullDay=Utils.parseInteger(strValue);
	}
	
	/**
	* 注册满天数领       
	**/
	public void setFullDay(Integer fullDay){
		this.fullDay = fullDay;
		this.setSeted(F.fullDay);
	}
	
	
	
	
	/*******************************指定用户**********************************/	
	/**
	* 指定用户  [Member]     
	**/
	public Long getDesigUser(){
		if(this.desigUser!=null){
			return this.desigUser;
		}
		return this.desigUser;
	}
	/**
	* 获取指定用户格式化(toString)
	**/
	public String getDesigUser$(){
		String strValue="";
		if(this.getDesigUser()!=null){
				strValue+=Utils.string(Member.getKeyValue(this.getDesigUser()));
		}			
	 	 return strValue;
	}
	/**
	* 根据指定用户反格式化
	**/
	public void setDesigUser$(String strValue){
		if(Utils.empty(strValue)){
			this.desigUser=null;
			return;
		}
		Member item = Member.find(strValue);
		if(item!=null){
			this.desigUser = Utils.parseLong(item.getId());
		}
	}
	
	/**
	* 指定用户  [Member]     
	**/
	public void setDesigUser(Long desigUser){
		this.desigUser = desigUser;
		this.setSeted(F.desigUser);
	}
	
	
	
	
	/**
	* 获取关联对象[会员信息]
	**/	 			
 	public Member get$desigUser(){
 		if(this.$desigUser!=null)
 			return this.$desigUser;
 		com.distribute.framework.model.Member member = null;
		if(this.getDesigUser()!=null){
 			member = Member.get(this.getDesigUser());
 		}
 		return member;
	}
	/*******************************已领取数量**********************************/	
	/**
	* 已领取数量 [非空]      
	**/
	public Integer getReceived(){
		if(this.received!=null){
			return this.received;
		}
		return this.received;
	}
	/**
	* 获取已领取数量格式化(toString)
	**/
	public String getReceived$(){
		String strValue="";
		 strValue=Utils.string(this.getReceived());
	 	 return strValue;
	}
	/**
	* 根据已领取数量反格式化
	**/
	public void setReceived$(String strValue){
		if(Utils.empty(strValue)){
			this.received=null;
			return;
		}
	 	this.received=Utils.parseInteger(strValue);
	}
	
	/**
	* 已领取数量 [非空]      
	**/
	public void setReceived(Integer received){
		this.received = received;
		this.setSeted(F.received);
	}
	
	
	
	
	/*******************************已使用数量**********************************/	
	/**
	* 已使用数量 [非空]      
	**/
	public Integer getUsed(){
		if(this.used!=null){
			return this.used;
		}
		return this.used;
	}
	/**
	* 获取已使用数量格式化(toString)
	**/
	public String getUsed$(){
		String strValue="";
		 strValue=Utils.string(this.getUsed());
	 	 return strValue;
	}
	/**
	* 根据已使用数量反格式化
	**/
	public void setUsed$(String strValue){
		if(Utils.empty(strValue)){
			this.used=null;
			return;
		}
	 	this.used=Utils.parseInteger(strValue);
	}
	
	/**
	* 已使用数量 [非空]      
	**/
	public void setUsed(Integer used){
		this.used = used;
		this.setSeted(F.used);
	}
	
	
	
	
	/*******************************适用商品**********************************/	
	/**
	* 适用商品 [非空] [Commodity]     
	**/
	public Long getCommodity(){
		if(this.commodity!=null){
			return this.commodity;
		}
		return this.commodity;
	}
	/**
	* 获取适用商品格式化(toString)
	**/
	public String getCommodity$(){
		String strValue="";
		if(this.getCommodity()!=null){
				strValue+=Utils.string(Commodity.getKeyValue(this.getCommodity()));
		}			
	 	 return strValue;
	}
	/**
	* 根据适用商品反格式化
	**/
	public void setCommodity$(String strValue){
		if(Utils.empty(strValue)){
			this.commodity=null;
			return;
		}
		Commodity item = Commodity.find(strValue);
		if(item!=null){
			this.commodity = Utils.parseLong(item.getId());
		}
	}
	
	/**
	* 适用商品 [非空] [Commodity]     
	**/
	public void setCommodity(Long commodity){
		this.commodity = commodity;
		this.setSeted(F.commodity);
	}
	
	
	
	
	/**
	* 获取关联对象[商品信息]
	**/	 			
 	public Commodity get$commodity(){
 		if(this.$commodity!=null)
 			return this.$commodity;
 		com.distribute.framework.model.Commodity commodity = null;
		if(this.getCommodity()!=null){
 			commodity = Commodity.get(this.getCommodity());
 		}
 		return commodity;
	}
	/*******************************修改时间**********************************/	
	/**
	* 修改时间 [非空]      
	**/
	public Date getUpdateTime(){
		if(this.updateTime!=null){
			return this.updateTime;
		}
		return this.updateTime;
	}
	/**
	* 获取修改时间格式化(toString)
	**/
	public String getUpdateTime$(){
		String strValue="";
		 strValue=Utils.string(Utils.date(this.getUpdateTime(),"yyyy-MM-dd HH:mm:ss"));
	 	 return strValue;
	}
	/**
	* 根据修改时间反格式化
	**/
	public void setUpdateTime$(String strValue){
		if(Utils.empty(strValue)){
			this.updateTime=null;
			return;
		}
	 	this.updateTime=Utils.date(strValue,"yyyy-MM-dd HH:mm:ss");
	}
	
	/**
	* 修改时间 [非空]      
	**/
	public void setUpdateTime(Date updateTime){
		this.updateTime = updateTime;
		this.setSeted(F.updateTime);
	}
	
	
	
	
	/*******************************添加时间**********************************/	
	/**
	* 添加时间 [非空]      
	**/
	public Date getAddTime(){
		if(this.addTime!=null){
			return this.addTime;
		}
		return this.addTime;
	}
	/**
	* 获取添加时间格式化(toString)
	**/
	public String getAddTime$(){
		String strValue="";
		 strValue=Utils.string(Utils.date(this.getAddTime(),"yyyy-MM-dd HH:mm:ss"));
	 	 return strValue;
	}
	/**
	* 根据添加时间反格式化
	**/
	public void setAddTime$(String strValue){
		if(Utils.empty(strValue)){
			this.addTime=null;
			return;
		}
	 	this.addTime=Utils.date(strValue,"yyyy-MM-dd HH:mm:ss");
	}
	
	/**
	* 添加时间 [非空]      
	**/
	public void setAddTime(Date addTime){
		this.addTime = addTime;
		this.setSeted(F.addTime);
	}
	
	
	
	
	/*******************************状态**********************************/	
	/**
	* 状态 [非空]   1:正常 0:无效    
	**/
	public Short getStatus(){
		if(this.status!=null){
			return this.status;
		}
		return this.status;
	}
	/**
	* 获取状态格式化(toString)
	**/
	public String getStatus$(){
		String strValue="";
		 if(Utils.equals(Utils.string(this.getStatus()),"1"))
			strValue=Utils.string("正常");		 
		 if(Utils.equals(Utils.string(this.getStatus()),"0"))
			strValue=Utils.string("无效");		 
	 	 return strValue;
	}
	/**
	* 根据状态反格式化
	**/
	public void setStatus$(String strValue){
		if(Utils.empty(strValue)){
			this.status=null;
			return;
		}
		 if(Utils.equals(strValue,"正常"))
		 	this.status=Utils.parseShort("1");
		 if(Utils.equals(strValue,"无效"))
		 	this.status=Utils.parseShort("0");
	}
	
	/**
	* 状态 [非空]   1:正常 0:无效    
	**/
	public void setStatus(Short status){
		this.status = status;
		this.setSeted(F.status);
	}
	
	
	
	
	/************LAZY3Q_DEFINE_CODE************/
	/************LAZY3Q_DEFINE_CODE************/
	
	
	/**
	 * 触发器
	 */
	public static void on(Trigger.Index index,final Notify.Listener listener,Trigger.Type... types){
		Notify.on(DirectCoupon.class, index, listener, types);
	}
	public static void on(final Notify.Listener listener,String type){
		Notify.on(DirectCoupon.class, listener, type);
	}
	/**
	 * 当修改字段时
	 * @param filedName
	 * @param listener
	 */
	public static void on(String filedName,final Notify.Listener listener){
		Notify.on(DirectCoupon.class, listener, filedName);
	}
	/**
	 * 当修改字段为某值时
	 * @param filedName
	 * @param value
	 * @param listener
	 */
	public static void on(String filedName,Object value,final Notify.Listener listener){
		if(value==null)return;
		Notify.on(DirectCoupon.class, listener, filedName+"."+Utils.md5(""+value));
	}
	public void notify(String type){
		Trigger.on(DirectCoupon.class,type, this);
	}
	
	
	/**
	 * 用来获取当有字段关联对象时的获取方式,调用如${DirectCoupon.obj.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${DirectCoupon.$filedName}获取关联对象
	 */
	public Map getObj(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return DirectCoupon.class.getMethod("get$"+Utils.forMat(key.toString())).invoke(DirectCoupon.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 用来获取某字段格式化的获取方式,调用如${DirectCoupon.fmt.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${DirectCoupon.filedName$}获取某字段格式化
	 */
	public Map getFmt(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return DirectCoupon.class.getMethod("get"+Utils.ForMat(key.toString()+"$")).invoke(DirectCoupon.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 获取查询参数链式串
	 * @return
	 */
	public static @Deprecated M where(){ return new M(0); }
	public static @Deprecated M m(){ return new M(0); }
	public static M where = new M(0,true);
	public static @database(DatabaseNames.distribute_sys) class M extends IbatisMap{
		int type = 0; 
		M linked = null;
		Boolean proxy = false;
		public M set = null;
		public M(int type){
			this.type = type;
			if(this.type==0){
				set = new M(1,true);
				set.linked = this;
			}
		};
		public M(int type,Boolean proxy){
			this.type = type;
			this.proxy=proxy;
		};
		public M proxy(){
			M m = new M(this.type);//当前的对像
			if(this.type==0){
				m.set = new M(1,true);//set对象
				m.set.linked = m;
			}else{
				m.linked=this.linked;
				this.linked.linked=m;
			}
			return m;
		}
		public @Deprecated M set(){			
			M m = this;
			m.linked=new M(1);
			m.linked.linked=m;
			return m.linked;
		};
		public M on(IbatisMap value,C column,String joinColumn){if(proxy)return proxy().on(value,column,joinColumn);this.put(value.getClass().getDeclaringClass().getSimpleName(), value);value.put("on", column.toString());value.put("to", joinColumn);return this;};
		/** 编号 [非空]       **/
		public M id(Object id){if(proxy)return proxy().id(id);  this.put("id", id);return this;};
	 	/** and id is null */
 		public M idNull(){if(proxy)return proxy().idNull();if(this.get("idNot")==null)this.put("idNot", "");this.put("id", null);return this;};
 		/** not .... */
 		public M idNot(){if(proxy)return proxy().idNot();this.put("idNot", "not");return this;};
 		public M idNotNull(){if(proxy)return proxy().idNotNull();this.put("idNot", "not");this.put("id", null);return this;};
 		public M idNot(Object id){if(proxy)return proxy().idNot(id);this.put("idNot", "not");this.put("id", id);return this;};
		/** and id <= ? */
		public M idMin(Object min){if(proxy)return proxy().idMin(min);this.put("idMin", min);return this;};
		/** and id >= ? */
		public M idMax(Object max){if(proxy)return proxy().idMax(max);this.put("idMax", max);return this;};
		public M idIn(String ids){
			if(proxy)return proxy().idIn(ids);  this.put("idIn", ids);return this;
		};	
		public M merchant$on(Merchant.M value){if(proxy)return proxy().merchant$on(value);this.put("Merchant", value);value.put("on", "merchant");return this;};
		/** 所属品牌 [非空] [Merchant]      **/
		public M merchant(Object merchant){if(proxy)return proxy().merchant(merchant);  this.put("merchant", merchant);return this;};
	 	/** and merchant is null */
 		public M merchantNull(){if(proxy)return proxy().merchantNull();if(this.get("merchantNot")==null)this.put("merchantNot", "");this.put("merchant", null);return this;};
 		/** not .... */
 		public M merchantNot(){if(proxy)return proxy().merchantNot();this.put("merchantNot", "not");return this;};
 		public M merchantNotNull(){if(proxy)return proxy().merchantNotNull();this.put("merchantNot", "not");this.put("merchant", null);return this;};
 		public M merchantNot(Object merchant){if(proxy)return proxy().merchantNot(merchant);this.put("merchantNot", "not");this.put("merchant", merchant);return this;};
		public M merchantIn(String ids){
			if(proxy)return proxy().merchantIn(ids);  this.put("merchantIn", ids);return this;
		};	
		/** 优惠券名称 [非空]       **/
		public M title(Object title){if(proxy)return proxy().title(title);  this.put("title", title);return this;};
	 	/** and title is null */
 		public M titleNull(){if(proxy)return proxy().titleNull();if(this.get("titleNot")==null)this.put("titleNot", "");this.put("title", null);return this;};
 		/** not .... */
 		public M titleNot(){if(proxy)return proxy().titleNot();this.put("titleNot", "not");return this;};
 		public M titleNotNull(){if(proxy)return proxy().titleNotNull();this.put("titleNot", "not");this.put("title", null);return this;};
 		public M titleNot(Object title){if(proxy)return proxy().titleNot(title);this.put("titleNot", "not");this.put("title", title);return this;};
		/** 生成数量 [非空]       **/
		public M count(Object count){if(proxy)return proxy().count(count);  this.put("count", count);return this;};
	 	/** and count is null */
 		public M countNull(){if(proxy)return proxy().countNull();if(this.get("countNot")==null)this.put("countNot", "");this.put("count", null);return this;};
 		/** not .... */
 		public M countNot(){if(proxy)return proxy().countNot();this.put("countNot", "not");return this;};
 		public M countNotNull(){if(proxy)return proxy().countNotNull();this.put("countNot", "not");this.put("count", null);return this;};
 		public M countNot(Object count){if(proxy)return proxy().countNot(count);this.put("countNot", "not");this.put("count", count);return this;};
		/** and count <= ? */
		public M countMin(Object min){if(proxy)return proxy().countMin(min);this.put("countMin", min);return this;};
		/** and count >= ? */
		public M countMax(Object max){if(proxy)return proxy().countMax(max);this.put("countMax", max);return this;};
		public M countIn(String ids){
			if(proxy)return proxy().countIn(ids);  this.put("countIn", ids);return this;
		};	
		/** 折扣 [非空]    最大设9.9折 不能大于等于10  也不能为负数   **/
		public M discount(Object discount){if(proxy)return proxy().discount(discount);  this.put("discount", discount);return this;};
	 	/** and discount is null */
 		public M discountNull(){if(proxy)return proxy().discountNull();if(this.get("discountNot")==null)this.put("discountNot", "");this.put("discount", null);return this;};
 		/** not .... */
 		public M discountNot(){if(proxy)return proxy().discountNot();this.put("discountNot", "not");return this;};
 		public M discountNotNull(){if(proxy)return proxy().discountNotNull();this.put("discountNot", "not");this.put("discount", null);return this;};
 		public M discountNot(Object discount){if(proxy)return proxy().discountNot(discount);this.put("discountNot", "not");this.put("discount", discount);return this;};
		/** and discount <= ? */
		public M discountMin(Object min){if(proxy)return proxy().discountMin(min);this.put("discountMin", min);return this;};
		/** and discount >= ? */
		public M discountMax(Object max){if(proxy)return proxy().discountMax(max);this.put("discountMax", max);return this;};
		/** 规则介绍 [非空]       **/
		public M introduction(Object introduction){if(proxy)return proxy().introduction(introduction);  this.put("introduction", introduction);return this;};
	 	/** and introduction is null */
 		public M introductionNull(){if(proxy)return proxy().introductionNull();if(this.get("introductionNot")==null)this.put("introductionNot", "");this.put("introduction", null);return this;};
 		/** not .... */
 		public M introductionNot(){if(proxy)return proxy().introductionNot();this.put("introductionNot", "not");return this;};
 		public M introductionNotNull(){if(proxy)return proxy().introductionNotNull();this.put("introductionNot", "not");this.put("introduction", null);return this;};
 		public M introductionNot(Object introduction){if(proxy)return proxy().introductionNot(introduction);this.put("introductionNot", "not");this.put("introduction", introduction);return this;};
		/** 截止时间 [非空]       **/
		public M deadline(Object deadline){if(proxy)return proxy().deadline(deadline);  this.put("deadline", deadline);return this;};
	 	/** and deadline is null */
 		public M deadlineNull(){if(proxy)return proxy().deadlineNull();if(this.get("deadlineNot")==null)this.put("deadlineNot", "");this.put("deadline", null);return this;};
 		/** not .... */
 		public M deadlineNot(){if(proxy)return proxy().deadlineNot();this.put("deadlineNot", "not");return this;};
 		public M deadlineNotNull(){if(proxy)return proxy().deadlineNotNull();this.put("deadlineNot", "not");this.put("deadline", null);return this;};
 		public M deadlineNot(Object deadline){if(proxy)return proxy().deadlineNot(deadline);this.put("deadlineNot", "not");this.put("deadline", deadline);return this;};
 		/** and deadline >= ? */
 		public M deadlineStart(Object start){if(proxy)return proxy().deadlineStart(start);this.put("deadlineStart", start);return this;};			
 		/** and deadline <= ? */
 		public M deadlineEnd(Object end){if(proxy)return proxy().deadlineEnd(end);this.put("deadlineEnd", end);return this;};
		/** 定向投放对象    1:全部用户 2:消费金额满 3:注册时间满 4:指定用户     **/
		public M directObject(Object directObject){if(proxy)return proxy().directObject(directObject);  this.put("directObject", directObject);return this;};
	 	/** and direct_object is null */
 		public M directObjectNull(){if(proxy)return proxy().directObjectNull();if(this.get("directObjectNot")==null)this.put("directObjectNot", "");this.put("directObject", null);return this;};
 		/** not .... */
 		public M directObjectNot(){if(proxy)return proxy().directObjectNot();this.put("directObjectNot", "not");return this;};
 		public M directObjectNotNull(){if(proxy)return proxy().directObjectNotNull();this.put("directObjectNot", "not");this.put("directObject", null);return this;};
 		public M directObjectNot(Object directObject){if(proxy)return proxy().directObjectNot(directObject);this.put("directObjectNot", "not");this.put("directObject", directObject);return this;};
		public M directObjectIn(String ids){
			if(proxy)return proxy().directObjectIn(ids);  this.put("directObjectIn", ids);return this;
		};	
		/** 消费累计满领        **/
		public M accumulatedFull(Object accumulatedFull){if(proxy)return proxy().accumulatedFull(accumulatedFull);  this.put("accumulatedFull", accumulatedFull);return this;};
	 	/** and accumulated_full is null */
 		public M accumulatedFullNull(){if(proxy)return proxy().accumulatedFullNull();if(this.get("accumulatedFullNot")==null)this.put("accumulatedFullNot", "");this.put("accumulatedFull", null);return this;};
 		/** not .... */
 		public M accumulatedFullNot(){if(proxy)return proxy().accumulatedFullNot();this.put("accumulatedFullNot", "not");return this;};
 		public M accumulatedFullNotNull(){if(proxy)return proxy().accumulatedFullNotNull();this.put("accumulatedFullNot", "not");this.put("accumulatedFull", null);return this;};
 		public M accumulatedFullNot(Object accumulatedFull){if(proxy)return proxy().accumulatedFullNot(accumulatedFull);this.put("accumulatedFullNot", "not");this.put("accumulatedFull", accumulatedFull);return this;};
		/** and accumulated_full <= ? */
		public M accumulatedFullMin(Object min){if(proxy)return proxy().accumulatedFullMin(min);this.put("accumulatedFullMin", min);return this;};
		/** and accumulated_full >= ? */
		public M accumulatedFullMax(Object max){if(proxy)return proxy().accumulatedFullMax(max);this.put("accumulatedFullMax", max);return this;};
		/** 注册满天数领        **/
		public M fullDay(Object fullDay){if(proxy)return proxy().fullDay(fullDay);  this.put("fullDay", fullDay);return this;};
	 	/** and full_day is null */
 		public M fullDayNull(){if(proxy)return proxy().fullDayNull();if(this.get("fullDayNot")==null)this.put("fullDayNot", "");this.put("fullDay", null);return this;};
 		/** not .... */
 		public M fullDayNot(){if(proxy)return proxy().fullDayNot();this.put("fullDayNot", "not");return this;};
 		public M fullDayNotNull(){if(proxy)return proxy().fullDayNotNull();this.put("fullDayNot", "not");this.put("fullDay", null);return this;};
 		public M fullDayNot(Object fullDay){if(proxy)return proxy().fullDayNot(fullDay);this.put("fullDayNot", "not");this.put("fullDay", fullDay);return this;};
		/** and full_day <= ? */
		public M fullDayMin(Object min){if(proxy)return proxy().fullDayMin(min);this.put("fullDayMin", min);return this;};
		/** and full_day >= ? */
		public M fullDayMax(Object max){if(proxy)return proxy().fullDayMax(max);this.put("fullDayMax", max);return this;};
		public M fullDayIn(String ids){
			if(proxy)return proxy().fullDayIn(ids);  this.put("fullDayIn", ids);return this;
		};	
		public M desigUser$on(Member.M value){if(proxy)return proxy().desigUser$on(value);this.put("DesigUser", value);value.put("on", "desig_user");return this;};
		/** 指定用户  [Member]      **/
		public M desigUser(Object desigUser){if(proxy)return proxy().desigUser(desigUser);  this.put("desigUser", desigUser);return this;};
	 	/** and desig_user is null */
 		public M desigUserNull(){if(proxy)return proxy().desigUserNull();if(this.get("desigUserNot")==null)this.put("desigUserNot", "");this.put("desigUser", null);return this;};
 		/** not .... */
 		public M desigUserNot(){if(proxy)return proxy().desigUserNot();this.put("desigUserNot", "not");return this;};
 		public M desigUserNotNull(){if(proxy)return proxy().desigUserNotNull();this.put("desigUserNot", "not");this.put("desigUser", null);return this;};
 		public M desigUserNot(Object desigUser){if(proxy)return proxy().desigUserNot(desigUser);this.put("desigUserNot", "not");this.put("desigUser", desigUser);return this;};
		public M desigUserIn(String ids){
			if(proxy)return proxy().desigUserIn(ids);  this.put("desigUserIn", ids);return this;
		};	
		/** 已领取数量 [非空]       **/
		public M received(Object received){if(proxy)return proxy().received(received);  this.put("received", received);return this;};
	 	/** and received is null */
 		public M receivedNull(){if(proxy)return proxy().receivedNull();if(this.get("receivedNot")==null)this.put("receivedNot", "");this.put("received", null);return this;};
 		/** not .... */
 		public M receivedNot(){if(proxy)return proxy().receivedNot();this.put("receivedNot", "not");return this;};
 		public M receivedNotNull(){if(proxy)return proxy().receivedNotNull();this.put("receivedNot", "not");this.put("received", null);return this;};
 		public M receivedNot(Object received){if(proxy)return proxy().receivedNot(received);this.put("receivedNot", "not");this.put("received", received);return this;};
		/** and received <= ? */
		public M receivedMin(Object min){if(proxy)return proxy().receivedMin(min);this.put("receivedMin", min);return this;};
		/** and received >= ? */
		public M receivedMax(Object max){if(proxy)return proxy().receivedMax(max);this.put("receivedMax", max);return this;};
		public M receivedIn(String ids){
			if(proxy)return proxy().receivedIn(ids);  this.put("receivedIn", ids);return this;
		};	
		/** 已使用数量 [非空]       **/
		public M used(Object used){if(proxy)return proxy().used(used);  this.put("used", used);return this;};
	 	/** and used is null */
 		public M usedNull(){if(proxy)return proxy().usedNull();if(this.get("usedNot")==null)this.put("usedNot", "");this.put("used", null);return this;};
 		/** not .... */
 		public M usedNot(){if(proxy)return proxy().usedNot();this.put("usedNot", "not");return this;};
 		public M usedNotNull(){if(proxy)return proxy().usedNotNull();this.put("usedNot", "not");this.put("used", null);return this;};
 		public M usedNot(Object used){if(proxy)return proxy().usedNot(used);this.put("usedNot", "not");this.put("used", used);return this;};
		/** and used <= ? */
		public M usedMin(Object min){if(proxy)return proxy().usedMin(min);this.put("usedMin", min);return this;};
		/** and used >= ? */
		public M usedMax(Object max){if(proxy)return proxy().usedMax(max);this.put("usedMax", max);return this;};
		public M usedIn(String ids){
			if(proxy)return proxy().usedIn(ids);  this.put("usedIn", ids);return this;
		};	
		public M commodity$on(Commodity.M value){if(proxy)return proxy().commodity$on(value);this.put("Commodity", value);value.put("on", "commodity");return this;};
		/** 适用商品 [非空] [Commodity]      **/
		public M commodity(Object commodity){if(proxy)return proxy().commodity(commodity);  this.put("commodity", commodity);return this;};
	 	/** and commodity is null */
 		public M commodityNull(){if(proxy)return proxy().commodityNull();if(this.get("commodityNot")==null)this.put("commodityNot", "");this.put("commodity", null);return this;};
 		/** not .... */
 		public M commodityNot(){if(proxy)return proxy().commodityNot();this.put("commodityNot", "not");return this;};
 		public M commodityNotNull(){if(proxy)return proxy().commodityNotNull();this.put("commodityNot", "not");this.put("commodity", null);return this;};
 		public M commodityNot(Object commodity){if(proxy)return proxy().commodityNot(commodity);this.put("commodityNot", "not");this.put("commodity", commodity);return this;};
		public M commodityIn(String ids){
			if(proxy)return proxy().commodityIn(ids);  this.put("commodityIn", ids);return this;
		};	
		/** 修改时间 [非空]       **/
		public M updateTime(Object updateTime){if(proxy)return proxy().updateTime(updateTime);  this.put("updateTime", updateTime);return this;};
	 	/** and update_time is null */
 		public M updateTimeNull(){if(proxy)return proxy().updateTimeNull();if(this.get("updateTimeNot")==null)this.put("updateTimeNot", "");this.put("updateTime", null);return this;};
 		/** not .... */
 		public M updateTimeNot(){if(proxy)return proxy().updateTimeNot();this.put("updateTimeNot", "not");return this;};
 		public M updateTimeNotNull(){if(proxy)return proxy().updateTimeNotNull();this.put("updateTimeNot", "not");this.put("updateTime", null);return this;};
 		public M updateTimeNot(Object updateTime){if(proxy)return proxy().updateTimeNot(updateTime);this.put("updateTimeNot", "not");this.put("updateTime", updateTime);return this;};
 		/** and update_time >= ? */
 		public M updateTimeStart(Object start){if(proxy)return proxy().updateTimeStart(start);this.put("updateTimeStart", start);return this;};			
 		/** and update_time <= ? */
 		public M updateTimeEnd(Object end){if(proxy)return proxy().updateTimeEnd(end);this.put("updateTimeEnd", end);return this;};
		/** 添加时间 [非空]       **/
		public M addTime(Object addTime){if(proxy)return proxy().addTime(addTime);  this.put("addTime", addTime);return this;};
	 	/** and add_time is null */
 		public M addTimeNull(){if(proxy)return proxy().addTimeNull();if(this.get("addTimeNot")==null)this.put("addTimeNot", "");this.put("addTime", null);return this;};
 		/** not .... */
 		public M addTimeNot(){if(proxy)return proxy().addTimeNot();this.put("addTimeNot", "not");return this;};
 		public M addTimeNotNull(){if(proxy)return proxy().addTimeNotNull();this.put("addTimeNot", "not");this.put("addTime", null);return this;};
 		public M addTimeNot(Object addTime){if(proxy)return proxy().addTimeNot(addTime);this.put("addTimeNot", "not");this.put("addTime", addTime);return this;};
 		/** and add_time >= ? */
 		public M addTimeStart(Object start){if(proxy)return proxy().addTimeStart(start);this.put("addTimeStart", start);return this;};			
 		/** and add_time <= ? */
 		public M addTimeEnd(Object end){if(proxy)return proxy().addTimeEnd(end);this.put("addTimeEnd", end);return this;};
		/** 状态 [非空]   1:正常 0:无效     **/
		public M status(Object status){if(proxy)return proxy().status(status);  this.put("status", status);return this;};
	 	/** and status is null */
 		public M statusNull(){if(proxy)return proxy().statusNull();if(this.get("statusNot")==null)this.put("statusNot", "");this.put("status", null);return this;};
 		/** not .... */
 		public M statusNot(){if(proxy)return proxy().statusNot();this.put("statusNot", "not");return this;};
 		public M statusNotNull(){if(proxy)return proxy().statusNotNull();this.put("statusNot", "not");this.put("status", null);return this;};
 		public M statusNot(Object status){if(proxy)return proxy().statusNot(status);this.put("statusNot", "not");this.put("status", status);return this;};
		public M statusIn(String ids){
			if(proxy)return proxy().statusIn(ids);  this.put("statusIn", ids);return this;
		};	
	 	public M add(String key, Object value) {if(proxy)return proxy().add(key,value);this.put(key, value);return this;}
	 	public M add(F key, Object value) {if(proxy)return proxy().add(key,value);this.put(key.toString(), value);return this;}
	 	public M desc(C key) {if(proxy)return proxy().desc(key);this.put("desc", key.column);return this;}
	 	public M asc(C key) {if(proxy)return proxy().asc(key);this.put("asc", key.column);return this;}
	 	public M desc(String sql) {if(proxy)return proxy().desc(sql);this.put("desc", sql);return this;}
	 	public M asc(String sql) {if(proxy)return proxy().asc(sql);this.put("asc", sql);return this;}
	 	public M definex(String sql) {if(proxy)return proxy().definex(sql);this.put("definex", sql);return this;}
	 	/** 获取所有定向优惠券 **/
		public @api List<DirectCoupon> list(Integer size){			
			return getDirectCouponList(this,size);
		}
		/** 获取定向优惠券分页 **/
		public @api Page<DirectCoupon> page(Integer page,Integer size){			
			return getDirectCouponPage(page, size , this);
		}
		/** 根据查询条件取定向优惠券 **/
		public @api DirectCoupon get(){			
			return getDirectCoupon(this);
		}
		/** 获取定向优惠券数 **/
		public @api Long count(){			
			return getDirectCouponCount(this);
		}
		/** 获取定向优惠券表达式 **/
		public @api <T> T eval(String strEval){			
			return getDirectCouponEval(strEval,this);
		}
		/** 获取定向优惠券统计 **/
		public @api List<Map> stats(C sumKey,C groupKey,int dateType){			
			return getDirectCouponStats(this,sumKey,groupKey,dateType);
		}
		/** 获取定向优惠券统计 **/
		public @api List<Map> stats(C sumKey,C groupKey){			
			return getDirectCouponStats(this,sumKey,groupKey,-1);
		}
		/** 根据条件更新 **/
		public @api int update(){			
			M where = null;
			M set = null;
			if(this.type==0){
				if(this.linked==null)throw new RuntimeException("未发set");
				where = this;
				set = this.linked;
			}else{
				if(this.linked==null)throw new RuntimeException("未发where条件");
				set = this;
				where = this.linked;
			}
			return updateDirectCoupon(set,where);
		}
		/** 根据条件删除 **/
		public @api void delete(){			
			deleteDirectCoupon(this);
		}
	}
	
	public static class Param extends M{
		public Param(int type) {
			super(type);
		}
		public Param(int type, Boolean proxy) {
			super(type, proxy);
		}
	}
	
	/** 对象的字段描述 **/
	public static class F{
		/** 编号 [非空]       **/
		public final static @type(Long.class)  String id="id";
		/** 所属品牌 [非空] [Merchant]      **/
		public final static @type(Long.class)  String merchant="merchant";
		/** 优惠券名称 [非空]       **/
		public final static @type(String.class)  String title="title";
		/** 生成数量 [非空]       **/
		public final static @type(Integer.class)  String count="count";
		/** and count >= ? */
		public final static @type(Integer.class) String countMin="countMin";
		/** and count <= ? */
		public final static @type(Integer.class) String countMax="countMax";
		/** 折扣 [非空]    最大设9.9折 不能大于等于10  也不能为负数   **/
		public final static @type(Double.class)  String discount="discount";
		/** and discount >= ? */
		public final static @type(Double.class) String discountMin="discountMin";
		/** and discount <= ? */
		public final static @type(Double.class) String discountMax="discountMax";
		/** 规则介绍 [非空]       **/
		public final static @type(String.class) @like String introduction="introduction";
		/** 截止时间 [非空]       **/
		public final static @type(Date.class)  String deadline="deadline";
	 	/** and deadline >= ? */
 		public final static @type(Date.class) String deadlineStart="deadlineStart";
 		/** and deadline <= ? */
 		public final static @type(Date.class) String deadlineEnd="deadlineEnd";
		/** 定向投放对象    1:全部用户 2:消费金额满 3:注册时间满 4:指定用户     **/
		public final static @type(Short.class)  String directObject="directObject";
		/** 消费累计满领        **/
		public final static @type(Double.class)  String accumulatedFull="accumulatedFull";
		/** and accumulated_full >= ? */
		public final static @type(Double.class) String accumulatedFullMin="accumulatedFullMin";
		/** and accumulated_full <= ? */
		public final static @type(Double.class) String accumulatedFullMax="accumulatedFullMax";
		/** 注册满天数领        **/
		public final static @type(Integer.class)  String fullDay="fullDay";
		/** and full_day >= ? */
		public final static @type(Integer.class) String fullDayMin="fullDayMin";
		/** and full_day <= ? */
		public final static @type(Integer.class) String fullDayMax="fullDayMax";
		/** 指定用户  [Member]      **/
		public final static @type(Long.class)  String desigUser="desigUser";
		/** 已领取数量 [非空]       **/
		public final static @type(Integer.class)  String received="received";
		/** and received >= ? */
		public final static @type(Integer.class) String receivedMin="receivedMin";
		/** and received <= ? */
		public final static @type(Integer.class) String receivedMax="receivedMax";
		/** 已使用数量 [非空]       **/
		public final static @type(Integer.class)  String used="used";
		/** and used >= ? */
		public final static @type(Integer.class) String usedMin="usedMin";
		/** and used <= ? */
		public final static @type(Integer.class) String usedMax="usedMax";
		/** 适用商品 [非空] [Commodity]      **/
		public final static @type(Long.class)  String commodity="commodity";
		/** 修改时间 [非空]       **/
		public final static @type(Date.class)  String updateTime="updateTime";
	 	/** and update_time >= ? */
 		public final static @type(Date.class) String updateTimeStart="updateTimeStart";
 		/** and update_time <= ? */
 		public final static @type(Date.class) String updateTimeEnd="updateTimeEnd";
		/** 添加时间 [非空]       **/
		public final static @type(Date.class)  String addTime="addTime";
	 	/** and add_time >= ? */
 		public final static @type(Date.class) String addTimeStart="addTimeStart";
 		/** and add_time <= ? */
 		public final static @type(Date.class) String addTimeEnd="addTimeEnd";
		/** 状态 [非空]   1:正常 0:无效     **/
		public final static @type(Short.class)  String status="status";
	 	public static String get(String name){
			try {
				Field field = F.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	/** 对象的数据库字段描述 **/
	public static enum C{
		id("id"),
		merchant("merchant"),
		title("title"),
		count("count"),
		discount("discount"),
		introduction("introduction"),
		deadline("deadline"),
		directObject("direct_object"),
		accumulatedFull("accumulated_full"),
		fullDay("full_day"),
		desigUser("desig_user"),
		received("received"),
		used("used"),
		commodity("commodity"),
		updateTime("update_time"),
		addTime("add_time"),
		status("status"),
		;
		String column;
		C(String column){
			this.column = column;
		}
		public String toString(){
			return this.column;
		}
		public static String get(String name){
			try {
				Field field = C.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	/**
	* 获取定向优惠券数据
	**/
	public static Object getData(Object param){
		if(param==null)
			return null;
		Object value = null;
		if(param.getClass()==Long.class)
			value = DirectCoupon.get((Long)param);
		else if(param instanceof java.util.Map){
			java.util.Map params = (Map) param;
			if(params.get("size")==null)
				value = DirectCoupon.getDirectCoupon(params);
			else
				value = DirectCoupon.getDirectCouponList(params, (Integer) params.get("size"));
		}else if(param.getClass()==Long.class )
			value =  DirectCoupon.where().id(param).get();
		else if(!Utils.empty(param.toString()))
			value = DirectCoupon.get(Long.valueOf(param.toString()));
		return value;
	}
	
	/**对象转json**/
	public Map toJSON(){
		return toJSON(false);
	}
	public Map toJSON(boolean simple){
		Map map = new HashMap();
		map.put("id",this.getId());
		Utils.fms(map,simple?"":"id",this.getId(),this.getId$());
		Utils.fms(map,simple?"":"merchant",this.getMerchant(),this.getMerchant$());
		Utils.fms(map,simple?"":"title",this.getTitle(),this.getTitle$());
		Utils.fms(map,simple?"":"count",this.getCount(),this.getCount$());
		Utils.fms(map,simple?"":"discount",this.getDiscount(),this.getDiscount$());
		Utils.fms(map,simple?"":"introduction",this.getIntroduction(),this.getIntroduction$());
		Utils.fms(map,simple?"":"deadline",this.getDeadline(),this.getDeadline$());
		Utils.fms(map,simple?"object":"directObject",this.getDirectObject(),this.getDirectObject$());
		Utils.fms(map,simple?"full":"accumulatedFull",this.getAccumulatedFull(),this.getAccumulatedFull$());
		Utils.fms(map,simple?"day":"fullDay",this.getFullDay(),this.getFullDay$());
		Utils.fms(map,simple?"user":"desigUser",this.getDesigUser(),this.getDesigUser$());
		Utils.fms(map,simple?"":"received",this.getReceived(),this.getReceived$());
		Utils.fms(map,simple?"":"used",this.getUsed(),this.getUsed$());
		Utils.fms(map,simple?"":"commodity",this.getCommodity(),this.getCommodity$());
		Utils.fms(map,simple?"time":"updateTime",this.getUpdateTime(),this.getUpdateTime$());
		Utils.fms(map,simple?"time":"addTime",this.getAddTime(),this.getAddTime$());
		Utils.fms(map,simple?"":"status",this.getStatus(),this.getStatus$());
		if(this.suffix!=null)map.put("suffix", this.suffix);
		/************LAZY3Q_DEFINE_TOJSON************/
		/************LAZY3Q_DEFINE_TOJSON************/
		return map;
	}
	/**对象转map**/
	public Map toMap(){
		Map map = new HashMap();
		map.put("id",this.getId());
		map.put("merchant",this.getMerchant());
		map.put("title",this.getTitle());
		map.put("count",this.getCount());
		map.put("discount",this.getDiscount());
		map.put("introduction",this.getIntroduction());
		map.put("deadline",this.getDeadline());
		map.put("directObject",this.getDirectObject());
		map.put("accumulatedFull",this.getAccumulatedFull());
		map.put("fullDay",this.getFullDay());
		map.put("desigUser",this.getDesigUser());
		map.put("received",this.getReceived());
		map.put("used",this.getUsed());
		map.put("commodity",this.getCommodity());
		map.put("updateTime",this.getUpdateTime());
		map.put("addTime",this.getAddTime());
		map.put("status",this.getStatus());
		map.put("suffix", this.suffix);
		/************LAZY3Q_DEFINE_TOMAP************/
		/************LAZY3Q_DEFINE_TOMAP************/
		return map;
	}
	/**map转对象**/
	public static DirectCoupon fromMap(Map map){
		DirectCoupon directCoupon = new DirectCoupon();
		directCoupon.id = Utils.parseLong(map.get("id"));
		directCoupon.merchant = Utils.parseLong(map.get("merchant"));
		directCoupon.title = Utils.parseString(map.get("title"));
		directCoupon.count = Utils.parseInteger(map.get("count"));
		directCoupon.discount = Utils.parseDouble(map.get("discount"));
		directCoupon.introduction = Utils.parseString(map.get("introduction"));
		directCoupon.deadline = Utils.parseDate(map.get("deadline"));
		directCoupon.directObject = Utils.parseShort(map.get("directObject"));
		directCoupon.accumulatedFull = Utils.parseDouble(map.get("accumulatedFull"));
		directCoupon.fullDay = Utils.parseInteger(map.get("fullDay"));
		directCoupon.desigUser = Utils.parseLong(map.get("desigUser"));
		directCoupon.received = Utils.parseInteger(map.get("received"));
		directCoupon.used = Utils.parseInteger(map.get("used"));
		directCoupon.commodity = Utils.parseLong(map.get("commodity"));
		directCoupon.updateTime = Utils.parseDate(map.get("updateTime"));
		directCoupon.addTime = Utils.parseDate(map.get("addTime"));
		directCoupon.status = Utils.parseShort(map.get("status"));
		return directCoupon;
	}
	
	
	
	/**字段设置标记队列**/
	private Map<String,Boolean> seted=new HashMap();
	public Boolean getSeted(String key){
		return seted.get(key);
	}
	public void setSeted(String key){
		seted.put(key,true);
	}
	/**同步未set的字段**/
	public void mergeSet(DirectCoupon old){
		Field[] fields = this.getClass().getDeclaredFields();
		try {
			for(Field field:fields){
				String key = field.getName();
				if(seted.get(key)==null && field.getAnnotation(column.class)!=null){
					field.setAccessible(true);
					field.set(this, field.get(old));					
				}
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
		
	/**自定义变量存储**/
	private Map values=new HashMap();
	public Map getValues(){
		return values;
	}
	public void setValues(String name,Object value){
		values.put(name,value);
	}
	
	/**分表时的表名后缀**/
	private String suffix;
	public String getSuffix() {
		return suffix;
	}
	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}
	/**获取数据库名称**/
	public static String getDataBaseName(){
		return Utils.config("spring.datasource.distribute_sys.name");
	}
	
	public static String getIcon(){
		return "/images/icons/Cash 2.png";
	}
	public static String getIconfont(){
		return "icon-qian";
	}
	public static enum ACT{
		列表,添加,修改,详情
	};
	public static String getUrl(ACT act,DirectCoupon.M params){
		if(params==null)params=new DirectCoupon.M(0);
		params.remove("joins");
		params.remove("definexs");
		params.remove("distinct");
		String strUrl = "/admin/coupons/directcoupon.edit.html?";
		if(params.get("id")!=null){
			strUrl+="&id="+Utils.encode(""+params.get("id"),Utils.UTF8);
		}
		if(act==ACT.列表){
			strUrl = "/admin/coupons/directcoupon.html?1=1";
		}else if(act==ACT.添加){
			strUrl+="&edittype=insert";
		}else if(act==ACT.修改){
			strUrl+="&edittype=update";
		}else if(act==ACT.详情){
			strUrl+="&edittype=detail";
		}		
		if(params!=null){
			for(Object key:params.keySet()){
				strUrl+="&"+key+"="+Utils.encode(""+params.get(key),Utils.UTF8)+"";
			}
		}
		return strUrl;
	}
	public String getDetailUrl(){
		return this.getUrl(ACT.详情, where.id(this.getId()));
	}
	
	/**
	* 转跳到当前地址
	**/
	public static Protocol redirect(DirectCoupon.ACT act,DirectCoupon.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_REDIRECT");
		protocol.set("url",DirectCoupon.getUrl(act, params));
		return protocol;
	}
	/**
	* 打开一个新的tab页面
	**/
	public static Protocol href(DirectCoupon.ACT act,DirectCoupon.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_HREF");
		protocol.set("url",DirectCoupon.getUrl(act, params));
		protocol.set("title",act.name());
		return protocol;
	}
	/**
	* 显示一个消息框，并且关闭当前的对话框
	**/
	public static Protocol message(String message){
		Protocol protocol = Protocol.create(true,null,"ACT_MESSAGE");
		protocol.set("message",message);
		return protocol;
	}
	
	
	static com.distribute.framework.dao.IDirectCouponDao getDirectCouponDao(){
		return Utils.getBean("directCouponDao");
	};
	
}